Ext.form.ItineraryList = Ext.extend(Ext.List, {
    title: 'Results',
    itemSelector: 'div.trip-list-item',
    //overClass: 'over',
    singleSelect: true,
    emptyText: 'No results.',
    isLoaded: false,
    scroll: 'both',

    initComponent: function () {

        Ext.regModel('Itinerary', {
            fields: [
            { name: 'ItineraryId', type: 'string' },
			{ name: 'StartTime', type: 'string' },
            { name: 'EndTime', type: 'string' },
            { name: 'Duration', type: 'string' },
            { name: 'WalkDistance', type: 'string' },
            { name: 'Distance', type: 'string' },
            { name: 'Transfers', type: 'string' },
            { name: 'LegsHtml', type: 'string' },
		    ]
        });


        var store = new Ext.data.Store({
            model: 'Itinerary'
        });

        this.store = store;

        this.tpl = new Ext.XTemplate(
        [
                    '<tpl for=".">',

                                '<div class="trip-list-item" id="{ItineraryId}">',
                                    '<span class="departure">{StartTime}</span>',
                                    '<span class="arrival">{EndTime}</span>',
                                    '<span class="duration">{Duration}</span>',
                                    '<span class="walk-duration">{WalkDistance}</span>',
                                    '<span class="route-duration">{Distance}</span>',
                                    '<span class="transfers">{Transfers}</span>',
                                    '<ul>{LegsHtml}</ul>',
                                '</div>',

                    '</tpl>',
                    '<div class="x-clear"></div>'

        ]
        );

        this.on('selectionchange', function (e, row, rowdata) {
            if (row.length == 0) {
                return;
            }
            setCard("trip-planner-legs");
            showLegs(rowdata[0].data.ItineraryId);
            //showPathOnMap(rowdata[0].data.ItineraryKmlUrl);
        });

        Ext.form.ItineraryList.superclass.initComponent.call(this);
    }
});

Ext.reg('itinerarylist', Ext.form.ItineraryList);

